home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Personal Computer World 2009 February
/
PCWFEB09.iso
/
Software
/
Resources
/
Chat & Communication
/
Digsby build 37
/
digsby_setup.exe
/
lib
/
oscar
/
Snactivator.pyo
(
.txt
)
< prev
Wrap
Python Compiled Bytecode
|
2008-10-13
|
3KB
|
93 lines
# Source Generated with Decompyle++
# File: in.pyo (Python 2.5)
from __future__ import with_statement
from itertools import count
from traceback import print_exc
from util import TimeOut, PriorityQueue, EmptyQueue
import logging
log = logging.getLogger('oscar.snactivator')
class Snactivator(TimeOut):
ids = count()
def __init__(self, socket):
TimeOut.__init__(self)
self.socket = socket
self.queues = [ PriorityQueue() for __ in xrange(len(socket.rate_classes)) ]
def send_snac(self, snac, priority = 5):
if self.finished():
log.error("Snactivator can't send this snace, because it's finished: %r", snac)
return None
rclass = self.socket.snac_rate_class(*snac)
if not rclass:
return self.socket._send_snac(snac)
self._cv.__enter__()
try:
queue = self.queues[self.socket.rate_classes.index(rclass)]
queue.append(snac, priority)
self._cv.notify()
finally:
pass
def compute_timeout(self):
if self.finished():
self._last_computed = -1
self.socket = None
else:
times = []
for q in (lambda .0: for queue in .0:
if queue:
queuecontinue)(self.queues):
snac = q.peek()
t = self.socket.time_to_send(snac)
times.append(t)
if not times:
pass
self._last_computed = min([
5])
return self._last_computed
def process(self):
for q in self.queues:
if not q:
continue
try:
snac = q.peek()
except EmptyQueue:
continue
t = self.socket.time_to_send(snac)
if t == 0 and not self.finished():
try:
snac = q.next()
except Exception:
return None
try:
self.socket._send_snac(snac)
except Exception:
print_exc()
self.socket.test_connection()
except:
None<EXCEPTION MATCH>Exception
None<EXCEPTION MATCH>Exception